<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctxPath" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<style>
body{ background:#E5E5E5; }
[type='text']{
	font-size:18px; background:#F3F3F3;
	margin-top:10px; border:1px solid #666;
	height:35px;
}
[type='button']{
	font-size:18px; margin-top:10px; 
	height:38px; width:100px;
}
[type='button']:hover{
	background:#D5D5D5; cursor:pointer;
	border:1px solid #666;
}
select {
	font-size:16px; margin-top:10px; 
	height:32px; width:180px;
	background:#E3E3E3;
}
textarea{
	background:#F3F3F3;margin-top:10px;
	font-size:17px;
}
#submit{
	margin-left: 80px;
}
#expensesBox{
	display: flex;
	align-items: center;
}
#expensesReason{
	padding-right: 5px;
}
</style>
<script src="${ctxPath}/static/js/jquery-1.11.1.min.js"></script>
<script>
function submitLeave(){
	$.ajax(
		{
			url:'${ctxPath}/Leave/submitLeave',
			type:'post',
			data:{
				initiator:$('#initiator').val(),
				startDate:$('#startDate').val(),
				endDate:$('#endDate').val(),
				leaveType:$('#leaveType').val(),
				reason:$('#reason').val()
			},
			dataType:"json",
			success:function( json ){
				console.log( json );
				var ret = json['result'];
				var cause = json['cause'];
				if (ret == 'success') {
					alert('成功提交报销申请');
					window.location = "${ctxPath}/Leave/myInitiate";
				} else {
					alert('报销申请提交失败,原因：'+cause);
				}
			}
		}		
	);
}
</script>

<form id="frmLeave">	
	<!--  发起人ID:initiator -->
	<input id="initiator" type="hidden" value="${user.id}"/><br/>
	
	<label>开始时间:</label>
	<input id="startDate" type="text" /><br/>
	
	<label>结束时间:</label>
	<input id="endDate" type="text" /><br/>
	
	<label>报销类型:</label>
	<select id="leaveType">
			<option value="0">请选择你的报销类型</option>
		<option value="客户应酬">客户应酬</option>
		<option value="联系业务">联系业务</option>
		<option value="采购物品">采购物品</option>
		<option value="参观学习">参观学习</option>
		<option value="公司调研">公司调研</option>
	</select><br/>

	<div id="expensesBox">
	<label id="expensesReason">支出详情:</label>
	<textarea id="reason" cols="35" rows="5"></textarea><br/>
	</div>
	<input type="button" value="申请报销" id="submit" onclick="submitLeave();"/>

</form>